package org.bingluo.livewallpaper.hunterxhunter;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import cn.waps.UpdatePointsNotifier;

import com.allcode.ad2.WPu;


public class HomeTabActivity extends TabActivity implements UpdatePointsNotifier{

	public static final String TAB1 = "1";

	public TabHost tabHost;
	
	private Intent intent_1;
	
	public WPu wpu = null;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_activity);
		wpu = new WPu(this, this);
		initView();
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		wpu.getPoints();
		super.onResume();
	}
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		wpu.onDestroy();
		super.onDestroy();
	}
	
	private void initView() {
		tabHost = this.getTabHost();
		
		intent_1 = new Intent(this, MainWallpaperServiceSettings.class);
		tabHost.addTab(addHost(TAB1, TAB1, intent_1));
		
		LinearLayout headAd = (LinearLayout)findViewById(R.id.headAd);
		LinearLayout sternAd = (LinearLayout)findViewById(R.id.sternAd);
//		wpu.addViewAd(headAd, sternAd);
	}
	
	public TabSpec addHost(String TabId, String TabName, Intent intent) {
		TabSpec tabSpec = tabHost.newTabSpec(TabId).setIndicator(TabName)
				.setContent(intent);
		return tabSpec;
	}

	@Override
	public void getUpdatePoints(String arg0, int arg1) {
		// TODO Auto-generated method stub
		wpu.integral = arg1;
	}

	@Override
	public void getUpdatePointsFailed(String arg0) {
		// TODO Auto-generated method stub
		
	}
}
